package gruppoC;

//TODO Servizio1 da implementare

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Servizio1 implements IServizio{
	
	private String nome;
	private int size;
	private String luogo;
	private String modello;
	private String data;





	@Override
	public ArrayList<String> getAnswer(String line) {
		
		tokenizer(line);
	
		try {
			File file = new File("db/eventi"+data+".xml");
			Writer writer = new FileWriter(file);
			
			BufferedReader reader = new BufferedReader(new FileReader(file));
			
			writer.close();
		} catch (FileNotFoundException e) {
			System.err.println("file not found");
			//openRequestedFile("/error.html");
		} catch (IOException e) {
			e.printStackTrace();
		}
	    
	    
	    return null;
	}

	
	
	
	
	private void tokenizer(String line) {
		StringTokenizer tokenizer = new StringTokenizer(line);
	    tokenizer.nextToken("=");
	    nome = tokenizer.nextToken("&");
	    tokenizer.nextToken("=");
	    size = Integer.parseInt(tokenizer.nextToken("&"));
	    tokenizer.nextToken("=");
	    luogo = tokenizer.nextToken("&");
	    tokenizer.nextToken("=");
	    modello = tokenizer.nextToken("&");
	    tokenizer.nextToken("=");
	    data = tokenizer.nextToken();
	}

}
